﻿using BlogApi.Models;
using BlogApi.ModelsDto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BlogApi.Services
{
    /// <summary>
    /// 评论表的仓储接口
    /// </summary>
    public interface ICommentRepository
    {
        /// <summary>
        /// 获取评论表的所有数据
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<Comment>> GetCommentsAsync();
        /// <summary>
        /// 获取分页后的评论表数据
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        Task<IEnumerable<Comment>> GetCommentsByPageAsync(int pageSize, int pageIndex);
        /// <summary>
        /// 获取评论表单个评论数据
        /// </summary>
        /// <param name="commentId"></param>
        /// <returns></returns>
        Task<Comment> GetCommentAsync(Guid commentId);
        /// <summary>
        /// 根据ID获取包含用户信息的评论数据
        /// </summary>
        /// <param name="commentId"></param>
        /// <returns></returns>
        Task<CommentAndUserInfoDto> GetCommentAndUserInfoAsync(Guid commentId);
        /// <summary>
        /// 获取某篇文章分页后的评论数据
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        Task<IEnumerable<CommentAndUserInfoDto>> GetArticleCommentAndUserInfoDtosByPageAsync(Guid articleId, int pageSize, int pageIndex);
        /// <summary>
        /// 新增一个评论
        /// </summary>
        /// <param name="comment"></param>
        void AddComment(Comment comment);
        /// <summary>
        /// 更新一个评论
        /// </summary>
        /// <param name="comment"></param>
        void UpdateComment(Comment comment);
        /// <summary>
        /// 删除一个评论
        /// </summary>
        /// <param name="comment"></param>
        void DeleteComment(Comment comment);
        /// <summary>
        /// 评论是否存在
        /// </summary>
        /// <param name="commentId"></param>
        /// <returns></returns>
        Task<bool> CommentExistsAsync(Guid commentId);
        /// <summary>
        /// 保存更改到数据库
        /// </summary>
        /// <returns></returns>
        Task<bool> SaveAsync();
    }
}
